package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.BillPlan;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class BillPlanVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "账单id")
    private Integer billId;

    @ApiModelProperty(value = "计划收款id")
    private Integer planId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static BillPlan convert(BillPlanVO vo) {
        BillPlan entity = new BillPlan();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<BillPlan> convertList(List<BillPlanVO> list) {
        List<BillPlan> resultList = new ArrayList<>();
        for (BillPlanVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
